import request from '@/utils/request'

const api = {
  page: '/socialOrganizationType/page',
  list: '/socialOrganizationType/list',
  socialOrganizationType: '/socialOrganizationType',
  tree: '/targetManagement/tree',
  treeByUser: '/targetManagement/treeByUser',
  targetManagement: '/targetManagement',
  targetManagementExpert: '/targetManagementExpert'
}

export function getCategory (parameter) {
  return request({
    url: api.page,
    method: 'get',
    params: parameter
  })
}

export function getCategoryList (parameter) {
  return request({
    url: api.list,
    method: 'get',
    params: parameter
  })
}

export function saveCategory (parameter) {
  return request({
    url: api.socialOrganizationType,
    method: parameter.id === 0 ? 'post' : 'put',
    data: parameter
  })
}

export function deleteCategory (parameter) {
  return request({
    url: api.socialOrganizationType + `/${parameter.id}`,
    method: 'delete'
  })
}

export function getQuotaTree (parameter) {
  return request({
    url: api.tree,
    method: 'get',
    params: parameter
  })
}
export function getQuotaTreeByUser (parameter) {
  return request({
    url: api.treeByUser,
    method: 'get',
    params: parameter
  })
}

export function getQuotaDetail (parameter) {
  return request({
    url: api.targetManagement + `/${parameter.id}`,
    method: 'get'
  })
}

export function saveQuota (parameter) {
  return request({
    url: api.targetManagement,
    method: parameter.id === 0 ? 'post' : 'put',
    data: parameter
  })
}

export function deleteQuota (parameter) {
  return request({
    url: api.targetManagement + `/${parameter.id}`,
    method: 'delete'
  })
}

export function assignQuota (parameter) {
  return request({
    url: api.targetManagementExpert,
    method: 'post',
    data: parameter
  })
}
